package com.lmonkey.servlet.my;

import com.lmonkey.servic.ADDRESSDao;
import com.lmonkey.shop.ADDRESS;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/shangc/doaddressadd")
public class DoAddressAdd extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置字符集
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=utf-8");

        //获取参数
        String name = request.getParameter("name");
        String id = request.getParameter("id");
        String mb = request.getParameter("mb");
        String ar = request.getParameter("ar");

        //加入数据库
        ADDRESSDao.add(name,id,mb,ar);
        //跳转页面
        String eids = request.getParameter("eids");
        if (eids != null){
            response.sendRedirect("orderselect?eids="+eids);
        }else{
            response.sendRedirect("addressselect");
        }

    }
}
